package me.zhengjie.modules.mes.excel;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import me.zhengjie.modules.mes.domain.vo.MesTemplateConfigData;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: some desc
 * @author: mfc
 * @date: 2025/1/2 15:15
 */
public class MesTemplateConfigListener extends AnalysisEventListener<MesTemplateConfigData> {

    private final List<MesTemplateConfigData> list = new ArrayList<>();

    @Override
    public void invoke(MesTemplateConfigData data, AnalysisContext context) {
        System.out.println("解析到一条数据: " + data);
        if(data == null || data.getComponentNameEn() == null){
            return;
        }
        list.add(data);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        System.out.println("所有数据解析完成！");
    }

    @Override
    public void onException(Exception exception, AnalysisContext context) {
        System.out.println("解析失败，但是继续解析下一行: " + exception.getMessage());
    }

    public List<MesTemplateConfigData> getDatas() {
        return list;
    }
}